package lc66;

import java.util.Scanner;

/**
 * @Author Stringzhua
 * @Date 2024/3/26 16:38
 * description:
 */
public class Test01 {
    public int[] plusOne(int[] digits) {
        for (int i = digits.length - 1; i >= 0; i--) {
            if (digits[i] != 9) {
                digits[i]++;
                return digits;
            }
            digits[i] = 0;
        }
        int temp[] = new int[digits.length + 1];//数组扩容
        temp[0] = 1;
        return temp;
    }

    public static void main(String[] args) {
        int[] digits = {4, 3, 2, 1};
        Test01 test01 = new Test01();
        test01.plusOne(digits);
        for (int i = 0; i < digits.length; i++) {
            System.out.print(i + " ");
        }
    }
}
